package com.model;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

public class CreateTabelSurat {

        public static void main(String[] args) {

        String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
        String userid = "PROJECT-PBO2"; // gantikan dengan username anda
        String password = "acong"; // gantikan dengan password anda
        Connection conn;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            Statement statement=conn.createStatement();
            System.out.println("Koneksi is OK");
            String sql2 = "CREATE TABLE SURAT("
                +"NO_SURAT VARCHAR2(20),"
                +"PERIHAL VARCHAR2(50),"
                +"ASAL_SURAT VARCHAR2(100),"
                +"PENERIMA_SURAT VARCHAR2(100),"
                +"RUANG VARCHAR2(50),"
                +"LEMARI VARCHAR2(10),"
                +"LOKER VARCHAR2(10), "
                +"PETUGAS_PENERIMA VARCHAR2(50),"
                +"TGL_MASUK DATE,"
                +"TIPE_FILE VARCHAR2(10),"
                +"STATUS VARCHAR2(10),"
                +"CONSTRAINT SURAT_PK PRIMARY KEY (NO_SURAT) ENABLE)";
                    statement.executeUpdate(sql2);
       } catch (SQLException e) {
        // perform error handling here
            System.out.println("error :"+ e.getMessage());
     }
   }
}
